Skip to content

Extract C++ FFI equivalence harness into a separate crate#2

Merged
werner291 merged 2 commits into
mainfrom
refactor/extract-equivalence-crate
Jun 1, 2026
Merged

Extract C++ FFI equivalence harness into a separate crate#2
werner291 merged 2 commits into
mainfrom
refactor/extract-equivalence-crate

Conversation

@werner291

Copy link
Copy Markdown
Owner

Pulls the original-MaxBin2 C++ and its FFI equivalence harness out of maxbin-rs into a new maxbin-rs-equivalence crate. The core now builds with no build.rs and no cc, which is the prerequisite for targeting wasm.

What moved: build.rs + vendor/ (the C++ extract/patch/compile), original_ffi.rs, the old cpp-em subcommand (now a maxbin-rs-cpp-em binary in the new crate), and the FFI and equivalence tests. The new crate path-depends on maxbin-rs; nothing in core had to be made more public.

No binning-output change: the only deletions from core are test functions, moved verbatim, and the EM itself is untouched.

One incidental fix rode along: bench-cpp-lto and disasm-em carried single-dash flags broken since v0.3, switched to double-dash while repointing them at the new binaries.

werner291 added 2 commits June 1, 2026 16:23
Move everything that links the original MaxBin2 C++ for FFI-based
equivalence testing out of the core maxbin-rs crate and into a new
crates/maxbin-rs-equivalence crate. The core crate now has no build.rs
and no cc / C++ dependency, so it can eventually compile to wasm.

What moved to crates/maxbin-rs-equivalence:
- build.rs and vendor/ (C++ extract, patch, and cc compile)
- src/original_ffi.rs (FFI bindings), re-exported from the crate's lib.rs
- the cpp-em capability, now the standalone maxbin-rs-cpp-em binary
  (it was only ever a maxbin-rs subcommand for equivalence testing)
- the FFI-comparing integration tests and proptests, plus the
  divergent-em fixture
- the in-source ffi_* / equivalence_* unit tests, relocated as
  integration tests that drive the core crate's public API

The new crate depends on maxbin-rs as a path dependency. No core API
needed widening: the moved tests already used public functions
(distance, kmer_map, profiler, emanager, fasta, abundance, quicksort).

Build wiring: the maxbin-rs and maxbin-rs-em packages now build only
-p maxbin-rs (coreArgs, no MAXBIN2_SRC_TARBALL). The workspace-wide
clippy and nextest checks still set the tarball because they span both
crates. The C++ LTO A/B benchmark and EM disassembly now use two new
equivalence-crate binaries (maxbin-rs-cpp-em, maxbin-rs-cpp-em-lto)
instead of the former maxbin-rs-lto.

This is pure code reorganization: the binning output of maxbin-rs on a
given input is unchanged.
…m binary

The equivalence-crate extraction moved the original C++ EM out of the
maxbin-rs `cpp-em` subcommand into a standalone maxbin-rs-cpp-em binary,
but two test paths still pointed at the old subcommand:

- pipeline-stages.sh Stage 4 called `maxbin-rs cpp-em`, which no longer
  exists. Switched to the maxbin-rs-cpp-em binary (same flags). The stage
  test stays: its EM comparison is single-shot via FFI, so it sidesteps
  the recursive ULP divergence that makes full end-to-end comparison
  flaky in degenerate cases.
- disasm-em pulled all four EM hot functions from the cpp-em binary, but
  that binary never calls the Rust EM, so run_em and
  compute_abund_prob_for_contig get dead-code-eliminated and the disasm
  silently degraded to "symbol not found". Pull the Rust functions from
  the maxbin-rs-em binary (unwrapped, runs the Rust EM via its pipeline)
  and keep the C++ functions on the cpp-em std/LTO binaries, which is the
  only axis the A/B actually varies.
@werner291 werner291 merged commit 3ae5797 into main Jun 1, 2026
1 check passed
@werner291 werner291 deleted the refactor/extract-equivalence-crate branch June 1, 2026 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant